<?php 
class Cms_Model_Contents
{
	public function saveData($data)
	{    
		if ( get_magic_quotes_gpc() )
			$postedValue = htmlspecialchars( stripslashes( $data['contents_des'] ) ) ;
		else
			$postedValue = htmlspecialchars( $data['contents_des'] ) ;
		$sqlData = array(
			'contents_title' => $data['contents_title'],
			'contents_img' => $data['contents_image'],
			'contents_des' => $postedValue,
			'contents_short_des' => $data['contents_short_des'],
			'contents_key' => $data['id'],
			'contents_status' => $data['contents_status'],
			'language' => $data['lang'],
		);
		$contentsDb = new Henry_Contents();
		//Kiem tra ton tai Content nay chua
              
		if ($contentsDb->checkExists($sqlData['contents_key'], $sqlData['language']))
		{
			return $contentsDb->editContent($sqlData);
		}
		else 
		{
			return $contentsDb->insert($sqlData);
		}
	}
	
}